package cn.doitedu.dw_utils

import cn.doitedu.dw_beans.ApplogBean
import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.expressions.GenericRow
import org.apache.spark.sql.expressions.MutableAggregationBuffer

object Row2Bean {

  def applogRow2Bean(row:Row):Option[ApplogBean]= {

    row match {
      case Row(
      account: String,
      appid: String,
      appversion: String,
      carrier: String,
      deviceid: String,
      devicetype: String,
      eventid: String,
      ip: String,
      latitude: Double,
      longitude: Double,
      nettype: String,
      osname: String,
      osversion: String,
      properties: Map[String, String],
      releasechannel: String,
      resolution: String,
      sessionid: String,
      timestamp: Long
      ) => Some(ApplogBean(
           account         ,
           appid           ,
           appversion      ,
           carrier         ,
           deviceid        ,
           devicetype      ,
           eventid         ,
           ip              ,
           latitude        ,
           longitude       ,
           nettype         ,
           osname          ,
           osversion       ,
           properties      ,
           releasechannel  ,
           resolution      ,
           sessionid       ,
           timestamp
      ))

      case _ =>  None
    }
  }
}
